import { LoginData, LoginResult } from './type';
import config from '../../../app.config';
import request from '../U9Request';
import { AxiosPromise } from 'axios';

/**
 *
 * @param info th|lf
 * @returns
 */
export function AuthLogin(info: string): AxiosPromise<LoginResult> {
  let data: LoginData;
  // 天河登录
  if (info == 'th' && !data) {
    data = {
      clientid: config.thInfo.clientid,
      clientsecret: config.thInfo.clientsecret,
      entCode: config.thInfo.EnterpriseId,
      orgCode: config.thInfo.OrgCode,
      userCode: config.thInfo.UserCode,
    };
  }
  // 鲁发登录
  if (info == 'lf' && !data) {
    data = {
      clientid: config.lfInfo.clientid,
      clientsecret: config.lfInfo.clientsecret,
      entCode: config.lfInfo.EnterpriseId,
      orgCode: config.lfInfo.OrgCode,
      userCode: config.lfInfo.UserCode,
    };
  }
  return request({
    url: '/webapi/OAuth2/AuthLogin',
    method: 'get',
    params: data,
  });
}
